<template>
    <div class="mainbody">
          <!-- 宝贝评价 -->
          <el-row>
                <div style="width: 80%;margin-left: 80px;" text-algin="left">
                    <div  v-for="(Comment,index) in FindCommentNull" :key="index">
                        <el-card style=" padding: 14px;">
                            <div>
                                <el-button type="warning" icon="el-icon-user-solid" circle></el-button>
                                <span>{{Comment.userName}}</span>
                            </div>
                            <div>
                                <el-rate v-model="Comment.goodsRating" show-text>
                                </el-rate>
                            </div>
                            <div>{{ Comment.goodsComment }}</div>
                        </el-card>
                    </div>
                </div>
            </el-row>
    </div>
</template>
  
  <script>
  import {getAllGoodsOrder,userInfo,findCommentByUserName,} from "../../../ajax/get"
//   import {addGoodsOrder} from "../ajax/post"
//   import defaultValue from "../utils/defalutValue"
  export default {
      name: "getGoodsOrder",
      data () {
          return {
            nickName: "", // 昵称
            userName:"",//用户名
            FindCommentByUserName:[],//根据用户名查找评价记录
            FindCommentNull:[],//评价记录为空
          };
      },
      methods: {
              // 查找用户信息
      findUserInfo(userName) {
        userInfo(userName).then(res => {
          console.log("用户信息:",res);
          this.nickName = res.data.data.nickName;
          this.userName = res.data.data.userName;
        })
        // 根据用户名查找评价记录
        findCommentByUserName(sessionStorage.getItem("userName")).then(com => {
            console.log(com,"评价记录");
            this.FindCommentByUserName = com.data.data;
            console.log(this.FindCommentByUserName,"新评价记录");
            for(let i in this.FindCommentByUserName){
                if(this.FindCommentByUserName[i].goodsComment!==""||this.FindCommentByUserName[i].goodsComment!==null){
                    this.$message.error("没有可评论的商品");
                }else{
                    this.FindCommentNull[i]=this.FindCommentByUserName[i].goodsComment;
                }
            }
            })
        },
        // 更新订单状态
        UpdateGoodsOrderById(Order){
            let goodsStatus=Order.goodsStatus+1;
            updateGoodsOrderById(goodsStatus,Order.id).then(res =>{
            console.log("更新订单状态:",res);
            })
        },
        // 删除订单
        DeleteGoodsBuyRecordsByUserNameAndBuyRecordId(Order){
            deleteGoodsBuyRecordsByUserNameAndBuyRecordId(Order.id,sessionStorage.getItem("userName")).then( res =>{
                console.log("删除订单",res);
                this.findUserInfo(sessionStorage.getItem("userName"));
            })
        },
      },
      created() {
      this.findUserInfo(sessionStorage.getItem("userName"));
          
      }
  }
  </script>
  
  <style scoped>
  </style>